
*------------------------------------------------------------------------------*
* Unweighted mean position of government
*
* Additional specs:
*	1. Excluding NONAs and parties with missing ideology
*	2. Fallback: 1st chamber median for expert governments
*
* Version:	2016-10-17
* Changes:	2016-??-??: First release
*------------------------------------------------------------------------------*

TEST

* Exclude NONAs and parties with missing ideology
gen filterno = p103 if p103 == 1 & $ideology != .
by g101 g105, sort: egen newsumno=sum(filterno)
gen newpofno = (filterno / newsumno * 100)

* Weigh new p% of cabinet seats with ideology
gen zs1 = ($ideology * newpofno) / 100

* Aggregate
by g101 g105, sort: egen GOV_POS = sum(zs1)
save zs, replace


* Fill in GOV_POS with fallback
replace GOV_POS = median1st if newsumno == 0 & GOV_POS == 0


* Cleansing
replace GOV_POS = . if g106 == 9

lab var GOV_POS "Position of government"

sort g101 g105 p101

capture: drop zs* filterno newsumno newpofno
capture: erase zs.dta
capture: erase zs_median.dta
